var myw = screen.availWidth * 0.5;
var myh = screen.availHeight* 0.7;
$(function() {

    //begin列表信息
    $("#chart_datagrid").datagrid({
        url: "/chart/queryTuition",
        columns: [[
            {field: "groupByType", title: "分组信息", width: 100},
            {field: "totalPaid", title: "已付总款", width: 100},
            {field: "totalUnPaid", title: "未付总款", width: 100}
        ]],
        fit: true,
        fitColumns: true,
        rownumbers: true,
        singleSelect: true,
        striped: true,
        pageNumber:1,
        toolbar: "#chart_tb"
    });
    //end列表信息

    //begin饼状图
    $("#pie_dialog").dialog({
        title: '饼状图',
        width: myw,
        height: myh,
        maximizable:true,
        minimizable:true,
        collapsible:true,
        closed: true,
        href: "/chart/pie"
    });
    //end饼状图

    //begin柱状图
    $("#bar_dialog").dialog({
        title: '柱状图',
        width: myw,
        height: myh,
        maximizable:true,
        minimizable:true,
        collapsible:true,
        closed: true,
        href: "/chart/bar"
    });
    //end柱状图



    //begin处理功能方法的对象
    var obj = {
        //begin查询按钮
        query:function () {
            var keyword = $("#keyword").textbox("getValue");
            var beginDate = $("#beginDate").datebox("getValue");
            var endDate = $("#endDate").datebox("getValue");
            var groupByType = $("#groupByType").combobox("getValue");
            $("#chart_datagrid").datagrid('load',{
                keyword:keyword,
                beginDate:beginDate,
                endDate:endDate,
                groupByType:groupByType
            })
        },
        //end查询按钮

        //begin饼状图按钮
        pie:function(){
            var args = $("input").serialize();
            $("#pie_dialog").dialog('center',{
                href: "/chart/pie"+'?'+args,
            })
            $("#pie_dialog").dialog("open");
        },
        //begin饼状图按钮

        //begin刷新按钮
        reload:function (){
            $("#chart_datagrid").datagrid("reload")
        },
        //end刷新按钮

        //begin柱状图按钮
        bar:function(){
            var args = $("input").serialize();
            $("#bar_dialog").dialog('center',{
                href: "/chart/bar"+'?'+args,
            })

            $("#bar_dialog").dialog("open");
        },
        //begin柱状图按钮



    };
    //end处理功能方法的对象

    //begin处理功能方法对象,实际调用方法
    $("a[data-cmd]").click(function(){
        var cmd = $(this).data("cmd");
        obj[cmd]();
    });
    //end处理功能方法对象,实际调用方法

});